package com.haibara.codesandbox.controller;

import cn.hutool.core.util.StrUtil;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/health")
public class HealthController {
    @Resource
    private Dashboard dashboard;

    @GetMapping("/checkHealth")
    public String health(@RequestParam("pwd") String pwd) {
        if (StrUtil.isBlankIfStr(pwd) || !"haibara".equals(pwd)) {
            return "无权限";
        }
        return dashboard.getTotalInfo();
    }
}
